package com.financing.wap.web.controller.adminapi;

import java.util.Collections;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.financing.wap.common.Pager;
import com.financing.wap.common.ResultMap;
import com.financing.wap.dto.DstNewrankArticleDTO;
import com.financing.wap.service.IDstNewrankArticleService;
import com.financing.wap.util.StringUtil;
import com.financing.wap.web.controller.BaseController;

@Controller("newrankArticleController")
@RequestMapping("/adminapi/newrankArticle")
public class DstNewrankArticleController extends BaseController  { 

	private Logger logger = Logger.getLogger(getClass());
	
	@Autowired
	IDstNewrankArticleService dstNewrankArticleService;
	
	
	
	@RequestMapping("/listNewrankArticle.shtml")
	@ResponseBody
	public ResultMap listNewrankArticle(HttpServletRequest request, DstNewrankArticleDTO dstNewrankArticle, Pager pager){
		ResultMap result = new ResultMap();
		
		try{
			logger.info("query admin listDstArticle list begin .......");

			dstNewrankArticle.setBegin(pager.getStartIndex());
			dstNewrankArticle.setPageSize(pager.getPageSize());
			List<DstNewrankArticleDTO> newrankArticleList = null;
			int count = dstNewrankArticleService.queryListCount(dstNewrankArticle);
			
			pager.setTotalCount(count);
			if(count > 0){
				newrankArticleList = dstNewrankArticleService.queryList(dstNewrankArticle);
			}else{
				newrankArticleList = Collections.emptyList();
			}
			
			result.setAttribute("list",newrankArticleList);
			
			result.setAttribute("pager", pager);
			result.setStatusCode(ResultMap.STATUS_CODE_SUCCESS);
			result.setStatus(ResultMap.STATUS.SUCCESS);
			
			logger.info("query dstArticle list end .......");
		}catch(Exception e){
			log.error("query dstArticle error!",e);
			result.setStatus(ResultMap.STATUS.ERROR);
			result.setStatusCode(ResultMap.STATUS_CODE_SYS_EXCEPTION);
		}
		return result;
	}
	
	
}
